<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
	template="template.xhtml">

	<ui:define name="content">

		<h:outputStylesheet target="head" library="css" name="no_border.css" />

		<h1>Tag Search</h1>

		<h:form id="form">

			<p:growl id="messages" showDetail="true" life="3000" />

			<p:panel header="Enter Tags" name="tagPanel">

				<p:messages />

				<p:outputLabel for="selectedTags" value="Tags:" />
				<p:autoComplete id="selectedTags" value="#{tagBean.selectedTags}"
					completeMethod="#{tagBean.completeTags}" var="t" itemLabel="#{t}"
					itemValue="#{t}" converter="tagConverter" multiple="true"
					global="false" />

				<p:commandButton value="Search" icon="ui-icon-check"
					style="margin:10px 0" action="#{tagBean.search}"
					update="placeResults tagResults" />

			</p:panel>

			<p:panel header="Place Results">
				<p:dataTable id="placeResults" value="#{tagBean.similarPlaces}"
					var="p" styleClass="table table-striped" paginator="true" rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15">
					<p:columnGroup type="header">
						<p:row>
							<p:column headerText="Place Name" />
							<p:column headerText="Country" />
							<p:column headerText="City" />
							<p:column headerText="Tags" />
						</p:row>

					</p:columnGroup>

					<p:column>
						<h:outputText value="#{p.placeName}" />
					</p:column>
					<p:column>
						<h:outputText value="#{p.country}" />
					</p:column>
					<p:column>
						<h:outputText value="#{p.city}" />
					</p:column>
					<p:column>
						<h:outputText value="#{p.CSVTags}" />
					</p:column>

				</p:dataTable>
			</p:panel>

			<p:panel header="Tag Results">
				<p:dataTable id="tagResults" value="#{tagBean.similarTags}" var="t"
					styleClass="table table-striped" paginator="true" rows="10"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="5,10,15">
					<p:columnGroup type="header">
						<p:row>
							<p:column headerText="MID" />
							<p:column headerText="Tag Name" />
							<p:column headerText="Notable Name" />
						</p:row>

					</p:columnGroup>

					<p:column>
						<h:outputLink value="http://www.freebase.com#{t.mID}">#{t.mID}</h:outputLink>
					</p:column>
					<p:column>
						<h:outputText value="#{t.tagName}" />
					</p:column>
					<p:column>
						<h:outputText value="#{t.notableName}" />
					</p:column>

				</p:dataTable>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
